package net.janeluo.rs.module;

import java.util.Calendar;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.janeluo.rs.service.OrdersCalendarService;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 订单日志
 * 
 * @author DLK)JaneLuo
 * @version 1.0.0
 */
@IocBean
@At("/")
public class OrdersCalendarManagerModule {
    
    @Inject
    private OrdersCalendarService ordersCalendarService;
    
    /**
     * 初始化显示订单日历
     * @return 
     */
    @At("OrdersCalendarManager")
    @Ok("jsp:views.OrdersCalendarManager")
    public List<List<Map<String, Object>>> initOrdersCalendarManager(HttpServletRequest req, @Param("year") Integer year, @Param("month") Integer month){
        
        Calendar cal = Calendar.getInstance();
        year = year == null ? cal.get(Calendar.YEAR) : year;
        month = month == null ? cal.get(Calendar.MONTH) + 1 : month;
        req.setAttribute("year", year);
        req.setAttribute("month", month);
        req.getSession().setAttribute("menuName", "OrdersCalendarManager");
        return ordersCalendarService.initCalendar(year, month);
    }

}
